package model

var RepositoryNames = struct { // repositories
	ProductTerm         string
	Product             string
	ProductDetail       string
	ProductRelationship string
	ProductMedia        string
	ProductAttribute    string
	ProductVariation    string
	ProductMeta         string
}{
	ProductTerm:         "ProductTerm",
	Product:             "Product",
	ProductDetail:       "ProductDetail",
	ProductRelationship: "ProductRelationship",
	ProductMedia:        "ProductMedia",
	ProductAttribute:    "ProductAttribute",
	ProductVariation:    "ProductVariation",
	ProductMeta:         "ProductMeta",
}

var RepositoryPreloadMap = map[string]map[string]string{
	RepositoryNames.ProductTerm: { // #24.07.10#
		"Id":              ProductTermColumns.TermID,
		"Name":            ProductTermColumns.Name,
		"Slug":            ProductTermColumns.Slug,
		"Taxonomy":        ProductTermColumns.Taxonomy,
		"ParentId":        ProductTermColumns.ParentID,
		"GroupId":         ProductTermColumns.TermGroup,
		"Count":           ProductTermColumns.Count,
		"Content":         ProductTermColumns.Description,
		"FilteredContent": ProductTermColumns.DescriptionFiltered,
		"Status":          ProductTermColumns.Status,
		"SortOrder":       ProductTermColumns.Sort,
	},
	RepositoryNames.Product: { // #24.07.10# 完成
		"Id":          ProductProductColumns.ID,
		"CategoryId":  ProductProductColumns.CategoryID,
		"ParentId":    ProductProductColumns.ParentID,
		"AuthorId":    ProductProductColumns.ProductAuthorID,
		"ProductCode": ProductProductColumns.ProductCode,
		"Title":       ProductProductColumns.Title,
		"Slug":        ProductProductColumns.Slug,
		"Excerpt":     ProductProductColumns.Excerpt,
		"Uri":         ProductProductColumns.GUID,
		"Link":        ProductProductColumns.GUID,
		"Status":      ProductProductColumns.Status,
		"CreatedAt":   ProductProductColumns.ProductDate,
		"UpdatedAt":   ProductProductColumns.ProductModifiedDate,
		"SortOrder":   ProductProductColumns.SortOrder,
		"virtual":     ProductProductColumns.VirtualType,
		"sticky":      ProductProductColumns.SortOrder,
	},
	RepositoryNames.ProductDetail: { // #24.07.12# 完成
		"Content":         ProductDetailColumns.Content,
		"FilteredContent": ProductDetailColumns.ContentFiltered,
		"Tracing":         ProductDetailColumns.Tracing,
		"FilteredTracing": ProductDetailColumns.TracingFiltered,
	},
	RepositoryNames.ProductRelationship: { // #24.07.11#
		"ProductId":   ProductKnowledgeBaseRelationshipColumns.ProductID,
		"PerfumeId":   ProductKnowledgeBaseRelationshipColumns.ToEntryID,
		"PerfumeName": ProductKnowledgeBaseRelationshipColumns.ToEntryName,
		"PerfumeSlug": ProductKnowledgeBaseRelationshipColumns.ToEntrySlug,
		"BrandId":     ProductKnowledgeBaseRelationshipColumns.ToEntryGroupID,
		"BrandName":   ProductKnowledgeBaseRelationshipColumns.ToEntryGroupName,
		"BrandSlug":   ProductKnowledgeBaseRelationshipColumns.ToEntryGroupSlug,
	},
	RepositoryNames.ProductMedia: { // #24.07.10#
		"Uid":       ProductAttachmentRelationshipColumns.AttachmentRelationshipID,
		"Id":        ProductAttachmentRelationshipColumns.AttachmentID,
		"Thumbnail": ProductAttachmentRelationshipColumns.AttachmentThumbnail,
		"Order":     ProductAttachmentRelationshipColumns.AttachmentOrder,
		"Uri":       ProductAttachmentRelationshipColumns.AttachmentSource,
		"Url":       ProductAttachmentRelationshipColumns.AttachmentImageURL,
		"altText":   ProductAttachmentRelationshipColumns.AttachmentImageAlt,
		"metaData":  ProductAttachmentRelationshipColumns.AttachmentImageMeta,

		"sourceUrl":    ProductAttachmentRelationshipColumns.AttachmentImageURL,
		"mediaDetails": ProductAttachmentRelationshipColumns.AttachmentImageMeta,
	},
	RepositoryNames.ProductAttribute: { // #24.07.11#
		"Id":        ProductAttributeColumns.ProductAttributeID,
		"ProductId": ProductAttributeColumns.ProductID,
		"TermId":    ProductAttributeColumns.TermID,
		"Taxonomy":  ProductAttributeColumns.Taxonomy, // 分类属性ID
		"IsSku":     ProductAttributeColumns.IsVariationAttribute,
		"Name":      ProductAttributeColumns.Name,
		"Slug":      ProductAttributeColumns.Slug,
		"HasImage":  ProductAttributeColumns.HasImage,
	},
	RepositoryNames.ProductVariation: { // #24.07.11#
		"Id":           ProductVariationColumns.ProductVariationID,
		"ProductId":    ProductVariationColumns.ProductID,
		"GemPrice":     ProductVariationColumns.GemPrice,
		"RetailPrice":  ProductVariationColumns.RetailPrice,
		"CounterPrice": ProductVariationColumns.CounterPrice,
		"Weight":       ProductVariationColumns.Weight,
		"SkuCode":      ProductVariationColumns.SkuCode,
		"SkuType":      ProductVariationColumns.SkuType,
		"Status":       ProductVariationColumns.Status,
	},
	RepositoryNames.ProductMeta: { // #24.07.11# 完成
		"Id":        ProductMetumColumns.MetaID,
		"ProductId": ProductMetumColumns.ProductID,
		"MetaKey":   ProductMetumColumns.MetaKey,
		"MetaValue": ProductMetumColumns.MetaValue,
	},
}

var RpcEntityNames = struct { // rpc entities
	ProductTerm          string
	ProductTermMeta      string
	Product              string
	ProductDetail        string
	ProductRelationship  string
	ProductAttribute     string
	ProductVariation     string
	ProductMeta          string
	ProductVariationMeta string
	ProductMedia         string
}{
	ProductTerm:          "productTerm",
	ProductTermMeta:      "productTermMeta",
	Product:              "product",
	ProductDetail:        "productDetail",
	ProductRelationship:  "productRelationship",
	ProductAttribute:     "productAttribute",
	ProductVariation:     "productVariation",
	ProductMeta:          "productMeta",
	ProductVariationMeta: "productVariationMeta",
	ProductMedia:         "productMedia",
}

type ColumnSetting struct {
	Name          string // rpc column name
	RpcEntityName string // sqlboiler repository name
}

var RpcEntityPreloadMap = map[string]map[string]*ColumnSetting{
	RpcEntityNames.ProductTerm: {},
	RpcEntityNames.ProductTermMeta: {
		"mediaId": &ColumnSetting{ // ##25.03.27##
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{ // ##25.03.27##
			Name: "_thumbnail_url",
		},
	},
	RpcEntityNames.Product: {
		"content": &ColumnSetting{
			Name:          "content",
			RpcEntityName: RpcEntityNames.ProductDetail,
		},
	},
	RpcEntityNames.ProductDetail:       {},
	RpcEntityNames.ProductRelationship: {},
	RpcEntityNames.ProductAttribute:    {},
	RpcEntityNames.ProductVariation:    {},
	RpcEntityNames.ProductMeta: {
		"sellPoint": &ColumnSetting{
			Name: "_sell_point",
		},
		"gemPriceMin": &ColumnSetting{
			Name: "_gem_price_min",
		},
		"gemPriceMax": &ColumnSetting{
			Name: "_gem_price_max",
		},
		"retailPriceMin": &ColumnSetting{ // #24.07.10#
			Name: "_retail_price_min",
		},
		"retailPriceMax": &ColumnSetting{
			Name: "_retail_price_max",
		},
		"couterPriceMin": &ColumnSetting{
			Name: "_couter_price_min",
		},
		"couterPriceMax": &ColumnSetting{
			Name: "_couter_price_max",
		},
		"scoreMin": &ColumnSetting{ // #24.08.22#
			Name: "_score_min",
		},
		"scoreMax": &ColumnSetting{
			Name: "_score_max",
		},
		"mediaId": &ColumnSetting{ // #24.07.10#
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{ // #24.07.10#
			Name: "_thumbnail_url",
		},
		"stock": &ColumnSetting{
			Name: "_stock",
		},
		"showStock": &ColumnSetting{
			Name: "_show_stock",
		},
		"stockUnit": &ColumnSetting{
			Name: "_stock_unit",
		},
		"sticky": &ColumnSetting{
			Name: "_sticky",
		},
		"reviewCount": &ColumnSetting{
			Name: "_review_count",
		},
		"saleCount": &ColumnSetting{
			Name: "_total_sale_count",
		},
		"ratingCount": &ColumnSetting{
			Name: "_rating_count",
		},
		"averageRating": &ColumnSetting{
			Name: "_average_rating",
		},
		"hotSell": &ColumnSetting{ // #24.07.10#
			Name: "_hot_sell",
		},
		"recommend": &ColumnSetting{ // #24.07.10#
			Name: "_recommend",
		},
	},
	RpcEntityNames.ProductVariationMeta: {
		"stock": &ColumnSetting{
			Name: "_stock",
		},
		"mediaId": &ColumnSetting{
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{
			Name: "_thumbnail_url",
		},
		"saleCount": &ColumnSetting{
			Name: "_pre_sale_count",
		},
		"totalSaleCount": &ColumnSetting{
			Name: "_total_sale_count",
		},
		"sku": &ColumnSetting{
			Name: "_sku",
		},
		"skuKey": &ColumnSetting{
			Name: "_sku_key",
		},
	},
	RpcEntityNames.ProductMedia: map[string]*ColumnSetting{},
}
